/*
 * @# SessionInterceptor.java 2011-12-27 下午04:24:11
 * 
 * Copyright (C) 2010 - 2011 广州羿安信息科技有限公司
 * Guangzhou ianswer information technology co. ltd.
 * 
 * All rights reserved!
 */
package com.ianswer.px.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.ianswer.px.common.SessionContextHolder;
import com.ianswer.px.user.entity.UserSession;

/**
 * session的拦截, 判断用户是否已登录.
 * 
 * @author alvin hwang
 */
public class SessionInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		if (null == SessionContextHolder.getUserId()) {
			UserSession user = new UserSession();
			user.setUserId(1L);
			user.setEmail("pananz@163.com");
			user.setUserType(0L);
			
			SessionContextHolder.currentUser(user);
		}
		return true;
	}
}
